package com.immediatus.graphics.vertex;

import com.immediatus.util.FastFloatBuffer;

public class LineVertexBuffer extends VertexBuffer{

    public static final int VERTICES_PER_LINE = 2;

    public LineVertexBuffer(final int drawType_, final boolean managed_){
        super(2 * VERTICES_PER_LINE, drawType_, managed_);
    }

    public synchronized void update(final float x1_, final float y1_, final float x2_, final float y2_){
        final int[] bufferData = this._BufferData;

        bufferData[0] = Float.floatToRawIntBits(x1_);
        bufferData[1] = Float.floatToRawIntBits(y1_);

        bufferData[2] = Float.floatToRawIntBits(x2_);
        bufferData[3] = Float.floatToRawIntBits(y2_);

        final FastFloatBuffer buffer = this._FloatBuffer;
        buffer.position(0);
        buffer.put(bufferData);
        buffer.position(0);

        super.setHardwareBufferNeedsUpdate();
    }
}
